<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>出库批次管理</title>
		<script type="text/javascript">
	$(function() {
		$("#inputForm").validate(); //为inputForm注册validate函数
		$("#beginTimeStr").datepicker({
			format : 'yyyy-mm-dd'
		});
		$("#endTimeStr").datepicker({
			format : 'yyyy-mm-dd'
		});

	});

	$(function() {
		$("#beginTimeStr").datepicker().on(
				'changeDate',
				function() {
					$("#inputForm").attr("action",
							"${ctx}/shippedBatch/batchLists/" + this.value);
					$("#inputForm").submit();
				});
	});

	function backupTaskLists() {
		$("#inputForm").attr("action",
				"${ctx}/shippedBatch/batchLists/" + $("#beginTimeStr").val());
		$("#inputForm").submit();
	}

	function ajaxPutShippedBatch(item) {
		$.ajax({
			type : 'post',
			url : '${ctx}/shippedBatch/ajaxPutShippedBatch',
			data : 'backupTaskCode=' + item,
			dataType : 'json',
			success : function(data) {
				$("#content").html(data.content);
				$("#message").show();
			},

			error : function() {
				alert("服务器错误！！！");
			}
		});
	}

	function backupTaskLists() {
		var time = $("#beginTimeStr").val();
		if (time == "") {
			$("#inputFormTwo").attr("action",
					"${ctx}/shippedBatch/batchLists/pending");
		} else {
			$("#inputFormTwo").attr("action",
					"${ctx}/shippedBatch/batchLists/" + time);
		}

		$("#inputFormTwo").submit();
	}
</script>
	</head>
	<body>
		<div id="message" class="alert alert-success" style="display: none;">
			<span id="content"></span>
		</div>
		<div id="fullbg"></div>
		<div id="dialog">
			<div>
				<img src="${ctx }/static/022.gif"></img>
			</div>
		</div>
		<div class="row">
			<form method="post" id="inputForm" class="form-search">
				<label>
					时间:
				</label>
				<input type="text" id="beginTimeStr" value="${from}"
					class="input-large required" />
			</form>

			<form method="post" id="inputFormTwo" class="form-search">
				<label>
					类型:
				</label>
				<select name="search_EQ_type" class="input-medium" id="lineType">
					<option
						<c:if test="${param.search_EQ_type eq 'single'}"> selected</c:if>
						value="single">
						单件
					</option>
					<option
						<c:if test="${param.search_EQ_type eq 'multiple' }"> selected</c:if>
						value="multiple">
						多件
					</option>
					<option
						<c:if test="${param.search_EQ_type eq 'forward' }"> selected</c:if>
						value="forward">
						中转发
					</option>
				</select>
				<label>
					姓名:
				</label>
				<input type="text" id="username"
					value="${param.search_LIKE_username}" name="search_LIKE_username"
					class="input-large required" />
				<button type="button" onclick="backupTaskLists(this);" class="btn">
					查询
				</button>

			</form>
		</div>
		<table id="contentTable"
			class="table table-striped table-bordered table-condensed">
			<thead>
				<tr>
					<th>
						编号
					</th>
					<th>
						箱子数量
					</th>
					<!--<th>
						生成日期
					</th>
					<th>
						处理日期
					</th>
					--><th>
						订单数量
					</th>
					<th>
						商品数量
					</th>
					<th>
						商品种类
					</th>
					<th>
						类型
					</th>
					<th>
						批次类型
					</th>
					<th>网点</th>
					<th>
						操作人
					</th>
					<th>
						状态
					</th>

				</tr>
			</thead>
			<tbody>
				<c:if test="${status eq 0 }">
					<c:forEach items="${object.content}" var="obj">
						<tr>
							<td>
								${obj.batchCode }
							</td>
							<td>
								<c:choose>
									<c:when test="${obj.boxQty ne 0 }">
										<a href="${ctx }/shippedBox/showBoxs/${obj.batchCode}">${obj.boxQty
											}</a>
									</c:when>
									<c:otherwise>
                                        ${obj.boxQty }
                                    </c:otherwise>
								</c:choose>


							</td>
							<!--<td>
								${obj.createDate }
							</td>
							<td>
								${obj.updateDate }
							</td>
							--><td>
								<a href="${ctx }/backupTask/showOrdenos/${obj.backupTaskCode}">${obj.ordenoQty
									}</a>
							</td>
							<td>
								${obj.skuQty }
							</td>
							<td>
								${obj.skuType }
							</td>
							<td>
								<c:if test="${obj.type eq 'single' }">
							     单件
							</c:if>
								<c:if test="${obj.type eq 'multiple' }">
							  多件
							</c:if>
								<c:if test="${obj.type eq 'forward' }">
							  中转发
							</c:if>
							</td>

							<td>
								<c:if test="${obj.batchType eq 'zwarehouse'}">
									<span class="label label-success">总仓订单</span>
								</c:if>
								<c:if test="${obj.batchType eq 'fwarehouse'}">
									<span class="label label-important">分仓订单</span>
								</c:if>
							</td>
							<td>
						 ${obj.areaGroupName }
						</td>
							<td>
								${obj.username }
							</td>
							<td>


								<c:if test="${obj.boxStatus eq 'pending'}">
									<a href="${ctx }/shippedBatch/shippedBoxSkus/${obj.batchCode}"
										class="btn btn-success">装箱</a>
								</c:if>

								<c:if test="${obj.boxStatus eq 'finish'}">
									<c:if test="${obj.status eq 'pending' }">
										<a
											href="javascript:ajaxPutShippedBatch('${obj.backupTaskCode}');"
											class="btn btn-danger">推送</a>
									</c:if>
									<c:if test="${obj.status eq 'finish' }">
										<a
											href="javascript:ajaxPutShippedBatch('${obj.backupTaskCode}');"
											class="btn btn-inverse">重新推送</a>
									</c:if>
								</c:if>
								<c:if test="${obj.type eq 'forward' }">
									<a
										href="${ctx }/printBackupTask/printInit/${obj.backupTaskCode}"
										class="btn btn-primary">重新打印</a>
								</c:if>
								<a class="btn"
									href="${ctx}/shippedBatch/exportExcel/${obj.backupTaskCode}">导出</a>

							</td>

						</tr>
					</c:forEach>
				</c:if>
				<c:if test="${status eq 1 }">
					<c:forEach items="${object}" var="obj">
						<tr>
							<td>
								${obj.batchCode }
							</td>
							<td>
								<c:choose>
									<c:when test="${obj.boxQty ne 0 }">
										<a href="${ctx }/shippedBox/showBoxs/${obj.batchCode}">${obj.boxQty
											}</a>
									</c:when>
									<c:otherwise>
                                        ${obj.boxQty }
                                    </c:otherwise>
								</c:choose>
							</td>
							<!--<td>
								${obj.createDate }
							</td>
							<td>
								${obj.updateDate }
							</td>
							--><td>
								<a href="${ctx }/backupTask/showOrdenos/${obj.backupTaskCode}">${obj.ordenoQty
									}</a>
							</td>
							<td>
								${obj.skuQty }
							</td>
							<td>
								${obj.skuType }
							</td>
							<td>
								<c:if test="${obj.type eq 'single' }">
							                      单件
							    </c:if>
								<c:if test="${obj.type eq 'multiple' }">
							                       多件
						     	</c:if>
								<c:if test="${obj.type eq 'forward' }">
							                       中转发
							    </c:if>
							</td>
							<td>
								<c:if test="${obj.batchType eq 'zwarehouse'}">
									<span class="label label-success">总仓订单</span>
								</c:if>
								<c:if test="${obj.batchType eq 'fwarehouse'}">
									<span class="label label-important">分仓订单</span>
								</c:if>
							</td>
							<td>
						 ${obj.areaGroupName }
						</td>
							<td>
								${obj.username }
							</td>
							<td>

								<c:if test="${obj.boxStatus eq 'pending'}">
									<a href="${ctx }/shippedBatch/shippedBoxSkus/${obj.batchCode}"
										class="btn btn-success">装箱</a>
								</c:if>

								<c:if test="${obj.boxStatus eq 'finish'}">
									<c:if test="${obj.status eq 'pending' }">
										<a
											href="javascript:ajaxPutShippedBatch('${obj.backupTaskCode}');"
											class="btn btn-danger">推送</a>
									</c:if>
									<c:if test="${obj.status eq 'finish' }">
										<a
											href="javascript:ajaxPutShippedBatch('${obj.backupTaskCode}');"
											class="btn btn-inverse">重新推送</a>
									</c:if>
								</c:if>
								<c:if test="${obj.type eq 'forward' }">
									<a
										href="${ctx }/printBackupTask/printInit/${obj.backupTaskCode}"
										class="btn btn-primary">重新打印</a>
								</c:if>

								<a class="btn"
									href="${ctx}/shippedBatch/exportExcel/${obj.backupTaskCode}">导出</a>
							</td>

						</tr>
					</c:forEach>
				</c:if>
			</tbody>
		</table>
		<c:if test="${status eq 0 }">
			<tags:pagination page="${object}" paginationSize="5" />
		</c:if>
	</body>
</html>